define(
	[
		'require'
	],
	function(require){
		var EmSet = Ember.set;
		var Controller = Ember.Controller.extend({
			logTypes: Ember.A([
				{
					name: "操作系统",
					code: "system",
					selected: true
				},
				{
					name: "协议分析器",
					code: "protocol"
				},
				{
					name: "指标运算服务",
					code: "indicator"
				},
				{
					name: "数据库",
					code: "database"
				}
			]),

			requireData: function(type){
				var ctrl = this;
				var parmas = {
					type: type ? type : this.get("logTypes").findBy("selected", true).code
				};

				if(isLocalDebugModel){
					parmas = undefined;
				}

				ctrl.store.ajax("GET", "logs", parmas)
				.then(function(response){
					ctrl.set("logBody", response.result.body);
				});
			},

			actions: {
				showLog: function(logType){
					EmSet(this.get("logTypes").findBy("selected", true), "selected", false);
					EmSet(logType, "selected", true);
					this.requireData(logType.code);
				}
			}
		});

		APM.ConfigLogsController = Controller;
		return Controller;
	}
);